﻿/* 2012/12/28 */
using System;
using System.Collections.Generic;
using System.Text;

namespace Cosmos.Collections.Generic
{
    /// <summary>
    /// Defines methods of a collection of duplicate values.
    /// All values which have the same key will be in a list.
    /// </summary>
    /// <typeparam name="TKey">The type of keys in the collection.</typeparam>
    /// <typeparam name="TValue">The type of values in the collection.</typeparam>
    public interface IDuplicateList<TKey, TValue>
    {
        bool Contains(TKey key);

        void Clear();

        /// <summary>
        /// Add a key without value. 
        /// If the key has not been added before, the key can be found but without any duplicated values.
        /// </summary>
        /// <param name="key"></param>
        void Add(TKey key);

        void Add(TKey key, TValue value);

        void Remove(TKey key);

        void Remove(TKey key, TValue value);

        /// <summary>
        /// Removes all values of a key except the specified value.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        void RemoveExcept(TKey key, TValue value);

        bool TryGetValues(TKey key, out TValue[] values);
    }
}
